package compilers.AST;

import java.io.PrintStream;

import compilers.compiler.PGenerator;
import compilers.exceptions.SemanticalException;
import compilers.symbolTable.SymbolTable;
import compilers.symbolTable.SymbolTableScope;


/**
 * @author  jens
 */
public class Tree {

	private Node fRoot;

	public Tree() {}
	
	public void addRoot(Node root) {
		fRoot = root;
	}
	
	public void print() {
		System.out.println("Abstract Syntax Tree");
		System.out.println("------------------------------------");
		if (fRoot != null) {
			fRoot.print(0);
		}
	}
	
	public void checkSemantics(SymbolTableScope currentScope) throws SemanticalException {
		if (fRoot != null) {
			fRoot.checkSemantics(currentScope);
		}
	}
	
	public void generatePcode(PGenerator pGen, SymbolTableScope currentScope) {
		fRoot.generatePcode(pGen, currentScope);
	}
}
